home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!nic.MR.NET!hal!ncoast!allbery
- From: waynet@mongo.UUCP (Wayne Thompson)
- Newsgroups: comp.sources.misc
- Subject: v05i065: nnscript (wrapper for enscript)
- Keywords: enscript ADOBE postscript
- Message-ID: <33537@mongo.uucp>
- Date: 3 Dec 88 00:34:21 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: waynet@mongo.UUCP (Wayne Thompson)
- Organization: Sun Microsystems, Inc. - Mtn View, CA
- Lines: 189
- Approved: allbery@ncoast.UUCP
-
- Posting-number: Volume 5, Issue 65
- Submitted-by: "Wayne Thompson" <waynet@mongo.UUCP>
- Archive-name: nnscript
-
- [enscript appears to be a program for translating ASCII files into
- PostScript code for printing on a PS printer. ++bsa]
-
- If you don't have enscript(1-local) then ignore this (or file for future
- reference). Buggestions, comments. flames? welcome.
- Wayne
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # nnscript
- # This archive created: Wed Nov 30 08:16:07 1988
- export PATH; PATH=/bin:/usr/bin:$PATH
- echo shar: "extracting 'nnscript'" '(4406 characters)'
- if test -f 'nnscript'
- then
- echo shar: "will not over-write existing file 'nnscript'"
- else
- sed 's/^ X//' << \SHAR_EOF > 'nnscript'
- X#! /bin/sh
- X#
- X# @(#)nnscript 1.0 (sun!waynet) 11/29/88
- X#
- XPATHNAME=oculus:/HOME/waynet/bin/nnscript
- X#
- X# Author: Wayne Thompson
- X#
- X# Description:
- X# This is a wrapper for enscript(1).
- X# 1. It prints an expanded Gaudy header. The header has
- X# a. full pathname
- X# b. file size in bytes
- X# c. user name in internet format
- X# d. '(folded)' if so
- X# 2. It prints using the least number of sheets (within reason)
- X# by fooling with the number of columns, rotation, and font
- X# size.
- X# 3. It prevents character lossage due to line length by
- X# fooling with the rotation, font size, and by folding as
- X# a last resort.
- X#
- X# enscript - Line & Page lengths for various options w/Gaudy
- X#
- X# font = Courier
- X# lnlen 2r R r pglen r R
- X# f10 62c 90c 125c f10 47l 64l
- X# f9 69c 101c 139c f9 52l 70l
- X# f8 77c 113c 156c f8 58l 78l
- X# f7 89c 129c 179c f7 65l 88l
- X# f6 209c
- X# f5 250c
- X#
- X# Options:
- X# -s Single column only.
- X# Anything that enscript understands.
- X#
- X# Files:
- X#
- X# Diagnostics:
- X#
- X# Dependencies:
- X# Above table applies only to Courier type face and Gaudy mode.
- X#
- X# Bugs:
- X# Each file is filtered through expand(1) and read by awk(1) to
- X# determine longest line, this can be slow for large files.
- X# A banner page is produced for each file.
- X#
- X
- Xfont=Courier # mono space typeface
- Xuser=${USER}@`hostname`
- X
- Xfor i
- Xdo
- X case $i in
- X -d) debug=true; shift;;
- X -s) sgl_col=true; shift;; # single column
- X -*) hard_opts="${hard_opts} \"$i\""; shift;;# buffer opts
- X *) break;;
- X esac
- Xdone
- X
- Xfor file
- Xdo
- X cd `dirname ${file}`
- X file=`basename ${file}`
- X pathname=`pwd`/${file}
- X if [ ! -f $pathname ]
- X then
- X echo "$pathname: No such file"
- X continue
- X fi
- X
- X cmd=`expand ${file} | awk '
- X {
- X l = length ($0);
- X if (l > ll)
- X ll = l; # longest line in file
- X }
- X
- X END {
- X opts = "-1Rf'"${font}"'10"; # default - 1col portrait 10pt
- X dp = int (NR / 64); if (NR % 64 > 0) dp++; # pgs for default
- X
- X if (ll > 179) {
- X cmd = "fold -176 '"${file}"' | ";
- X }
- X else {
- X cmd = "cat '"${file}"' | ";
- X }
- X cmd = cmd "enscript -GJ'"${file}"' ";
- X
- X if (ll > 156) {
- X opts = "-1rf'"${font}"'7"; # 1col landscape 7pt
- X }
- X else if (ll > 139) {
- X opts = "-1rf'"${font}"'8"; # 1col landscape 8pt
- X }
- X else if (ll > 125) {
- X opts = "-1rf'"${font}"'9"; # 1col landscape 9pt
- X }
- X else if (ll > 113) {
- X opts = "-1rf'"${font}"'10"; # 1col landscape 10pt
- X }
- X else if (ll > 101) {
- X opts = "-1Rf'"${font}"'8"; # 1col portrait 8pt
- X }
- X else if (ll > 90) {
- X opts = "-1Rf'"${font}"'9"; # 1col portrait 9pt
- X }
- X else if (ll > 89) {
- X opts = "-1Rf'"${font}"'10"; # 1col portrait 10pt
- X }
- X else if (ll > 77 && ll < 90 && "'"${sgl_col}"'" == "") {
- X np = int (NR / 130); if (NR % 130 > 0) np++;
- X if (dp > np)
- X opts = "-2rf'"${font}"'7"; # 2col landscape 7pt
- X }
- X else if (ll > 69 && "'"$sgl_col"'" == "") {
- X np = int (NR / 116); if (NR % 116 > 0) np++;
- X if (dp > np)
- X opts = "-2rf'"${font}"'8"; # 2col landscape 8pt
- X }
- X else if (ll > 62 && "'"$sgl_col"'" == "") {
- X np = int (NR / 104); if (NR % 104 > 0) np++;
- X if (dp > np)
- X opts = "-2rf'"${font}"'9"; # 2col landscape 9pt
- X }
- X else if ("'"$sgl_col"'" == "") {
- X np = int (NR / 94); if (NR % 94 > 0) np++;
- X if (dp > np)
- X opts = "2rf'"${font}"'10"; # 2col landscape 10pt
- X }
- X
- X if ("'"${debug}"'" == "true") {
- X printf ("ll = %d, NR = %d ,dp = %d, np = %d, cmd = ",\
- X ll, NR, dp, np);
- X }
- X print cmd opts;
- X }
- X '`
- X
- X size=`ls -l ${file} | awk '{ print $4 }'`
- X note=`echo ${cmd} | awk '/^fold/ { print " - (folded)"; }'`
- X header="${pathname}, ${size} bytes, ${user}${note}"
- X
- X if [ -n "$debug" ]
- X then
- X echo ${cmd} -b\"${header}\" ${hard_opts}
- X else
- X echo -n "${pathname} "
- X eval ${cmd} -b\"${header}\" ${hard_opts}
- X fi
- Xdone
- SHAR_EOF
- if test 4406 -ne "`wc -c < 'nnscript'`"
- then
- echo shar: "error transmitting 'nnscript'" '(should have been 4406 characters)'
- fi
- chmod +x 'nnscript'
- fi
- exit 0
- # End of shell archive
-